<?php

/**
 * Netdev filter form base class.
 *
 * @package    seth
 * @subpackage filter
 * @author     Fuz
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseNetdevFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'name'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'type'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'plant'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Plant'), 'add_empty' => true)),
      'system'       => new sfWidgetFormFilterInput(),
      'network'      => new sfWidgetFormFilterInput(),
      'ip1'          => new sfWidgetFormFilterInput(),
      'url'          => new sfWidgetFormFilterInput(),
      'user1'        => new sfWidgetFormFilterInput(),
      'pass1'        => new sfWidgetFormFilterInput(),
      'pingable'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'ip2'          => new sfWidgetFormFilterInput(),
      'ip3'          => new sfWidgetFormFilterInput(),
      'subnet'       => new sfWidgetFormFilterInput(),
      'gateway'      => new sfWidgetFormFilterInput(),
      'user2'        => new sfWidgetFormFilterInput(),
      'pass2'        => new sfWidgetFormFilterInput(),
      'note'         => new sfWidgetFormFilterInput(),
      'subplant'     => new sfWidgetFormFilterInput(),
      'manufacturer' => new sfWidgetFormFilterInput(),
      'model'        => new sfWidgetFormFilterInput(),
      'protocols'    => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'name'         => new sfValidatorPass(array('required' => false)),
      'type'         => new sfValidatorPass(array('required' => false)),
      'plant'        => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Plant'), 'column' => 'id')),
      'system'       => new sfValidatorPass(array('required' => false)),
      'network'      => new sfValidatorPass(array('required' => false)),
      'ip1'          => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'url'          => new sfValidatorPass(array('required' => false)),
      'user1'        => new sfValidatorPass(array('required' => false)),
      'pass1'        => new sfValidatorPass(array('required' => false)),
      'pingable'     => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'ip2'          => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'ip3'          => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'subnet'       => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'gateway'      => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'user2'        => new sfValidatorPass(array('required' => false)),
      'pass2'        => new sfValidatorPass(array('required' => false)),
      'note'         => new sfValidatorPass(array('required' => false)),
      'subplant'     => new sfValidatorPass(array('required' => false)),
      'manufacturer' => new sfValidatorPass(array('required' => false)),
      'model'        => new sfValidatorPass(array('required' => false)),
      'protocols'    => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('netdev_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Netdev';
  }

  public function getFields()
  {
    return array(
      'id'           => 'Number',
      'name'         => 'Text',
      'type'         => 'Text',
      'plant'        => 'ForeignKey',
      'system'       => 'Text',
      'network'      => 'Text',
      'ip1'          => 'Number',
      'url'          => 'Text',
      'user1'        => 'Text',
      'pass1'        => 'Text',
      'pingable'     => 'Number',
      'ip2'          => 'Number',
      'ip3'          => 'Number',
      'subnet'       => 'Number',
      'gateway'      => 'Number',
      'user2'        => 'Text',
      'pass2'        => 'Text',
      'note'         => 'Text',
      'subplant'     => 'Text',
      'manufacturer' => 'Text',
      'model'        => 'Text',
      'protocols'    => 'Text',
    );
  }
}
